import { reactive, nextTick } from "vue";

/** 默认的分页参数 */
const defaultPaginationData = {
  total: 0,
  currentPage: 1,
  pageSizes: ["10", "20", "50"],
  pageSize: "10",
};

export function usePagination() {
  /** 合并分页参数 */
  const paginationData = reactive({ ...defaultPaginationData });
  const showSizeChange = (current, pageSize) => {
    paginationData.pageSize = pageSize + "";
    nextTick(() => {
      paginationData.currentPage = 1;
    });
  };
  const pageChange = (current) => {
    paginationData.currentPage = current;
  };
  return { paginationData, pageChange, showSizeChange };
}
